/**
* @file         witdatapkg.h
* @author       David Hu (hmd_hubei_cn@163.com)
* @brief         
* @version      0.1
* @date         2024.10.16
* @note          
* @copyright    Copyright (c) 2022 DAVID HU All rights reserved. Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License in the file LICENSE
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

#ifndef __WITDATAPKG_H__
#define __WITDATAPKG_H__

#include "wit_motion_protocol.h"

namespace wit_private_msg {

typedef struct {
  float acc_x;
  float acc_y;
  float acc_z;
} WitImuAccelerometerType;

typedef struct {
  float angularvel_x;
  float angularvel_y;
  float angularvel_z;
} WitImuAngularvelType;

typedef struct {
  float angular_x;
  float angular_y;
  float angular_z;
} WitImuAngularType;

typedef struct {
  float current_pos_lng;
  float current_pos_lat;
  int actual_speed;
  int actual_altitude;
} WitGnssLocationType;

class WitDataPkg {
 public:
  WitDataPkg();

  ~WitDataPkg();

  void RecvDataCallback(const char* data, uint16_t len);

  WitImuAccelerometerType GetImuAccelerometerData(void) const;

  WitImuAngularvelType GetImuAngularvelData(void) const;

  WitImuAngularType GetImuAngularData(void) const;

  WitGnssLocationType GetGnssLocationData(void) const;

  bool IsImuDataReady(void);

  bool IsGnssDataReady(void);

 private:
  void ParseCmd(uint8_t data);

  uint8_t GetPackId(void);

  uint8_t* GetPackDataBuff(void);

  uint32_t GetPackDataLen(void);

  uint8_t unpack_buffer_[WIT_PKG_UNPACK_LEN];

  uint32_t unpack_data_buffer_len_;

  wit_packdata_t unpack_handle_;

  WitImuAccelerometerType imu_acc_;

  WitImuAngularvelType imu_angularvel_;

  WitImuAngularType imu_angular_;

  WitGnssLocationType gnss_locations_;

  bool is_imu_ready_;
  
  bool is_gnss_locations_ready_;
};

} // namespace wit_private_msg

#endif //__WITDATAPKG_H__
/********************* (C) COPYRIGHT DAVID HU *******END OF FILE ********/
